package com.sinosoft.oms.controller;

import com.sinosoft.oms.entity.oms.Appnt;
import com.sinosoft.oms.entity.oms.Insured;
import com.sinosoft.oms.entity.oms.Order;
import com.sinosoft.oms.entity.oms.Product;
import com.sinosoft.oms.service.BasicInfoService;
import com.sinosoft.oms.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.sql.SQLException;

/**
 * @author:Frankiegg
 * @Date:2018/5/7
 * @project:bee
 * @Modified By:
 **/
@RestController
@RequestMapping(value = "/order/basicinfo")
public class BasicInfoController {

    @Autowired
    @Qualifier("DealBasicInfo")
    private BasicInfoService basicInfoService;



    @Autowired
    private Result result;

    @GetMapping("/get")
    public String get(){
        return null;
    }

    @GetMapping("/notice/{riskcode}")
    public String getNotice(@PathVariable String riskcode){
        return null;
    }

    @RequestMapping(value = "/post",method = RequestMethod.POST)
    public Result post(@RequestBody @Valid Order order, @RequestBody Appnt appnt, @RequestBody Insured insured, @RequestBody Product product){
        System.out.println(order);
        System.out.println(appnt);
        System.out.println(insured);
        System.out.println(product);
        try {
            boolean postResult=basicInfoService.postBasicInfo(order,appnt,insured,product);
        }catch (SQLException e){
            e.printStackTrace();
        }
        return result;
    }

    @RequestMapping(value = "/put",method = RequestMethod.PUT)
    public String put(){
        return null;
    }

    @RequestMapping(value = "/patch",method = RequestMethod.PATCH)
    public String patch(){
        return null;
    }

    @RequestMapping(value = "/delete/",method = RequestMethod.DELETE)
    public String delete(@PathVariable String orderId){
        try{
            boolean deleteResult=basicInfoService.deleteBasicInfo(orderId);
        }catch (SQLException e){

        }
        return null;
    }
}
